import 'package:flutter/material.dart';

import 'tag_flow_widget.dart';

class GenresPage extends StatelessWidget {
  const GenresPage({super.key});

  @override
  Widget build(BuildContext context) {
    final List<String> genres = [
      "All",
      "Action",
      "Adventure",
      "Drama",
      "Magic",
      "Manhwa",
      "Martial Arts",
      "Seinen",
      "Fantasy",
    ];
    return Scaffold(
      appBar: AppBar(title: const Text("Genres")),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            const Text(
              "Genres",
              style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
            ),
            const SizedBox(height: 8),
            TagFlowWidget(
              items: genres,
              maxRows: 2, // 控制默认显示几行
              itemHeight: 32,
              selectedTextColor: Colors.purple, // 选中文字颜色，贴近示例风格
              unselectedTextColor: Colors.grey,
              onSelectedChanged: (selected) {
                debugPrint("选中的类型：$selected");
              },
            ),
            const SizedBox(height: 16),
            const Text(
              "Status",
              style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
            ),
            const SizedBox(height: 8),
            Wrap(
              spacing: 8,
              children: [
                _buildStatusChip("All", isSelected: true),
                _buildStatusChip("Ongoing"),
                _buildStatusChip("Completed", isSelected: true),
              ],
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildStatusChip(String text, {bool isSelected = false}) {
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
      decoration: BoxDecoration(
        color: isSelected ? Colors.purple : Colors.grey.shade300,
        borderRadius: BorderRadius.circular(20),
      ),
      child: Text(
        text,
        style: TextStyle(color: isSelected ? Colors.white : Colors.black),
      ),
    );
  }
}
